#ifndef _MESSAGE_HANDLERS_H_
#define _MESSAGE_HANDLERS_H_

#define DECLARE_MESSAGE_HANDLER() \
	virtual bool MessageHandler(unsigned int message, unsigned int wParam, long lParam, long* pResult)

#define BEGIN_MESSAGE_HANDLER(class) \
	bool class::MessageHandler(unsigned int message, unsigned int wParam, long lParam, long* pResult)\
	{\
		*pResult = 0;

#define END_MESSAGE_HANDLER() \
		return false;\
	}

#define ON_NOTIFY_MSG(Code, Id, handler) \
	if(message == WM_NOTIFY && ((LPNMHDR)lParam)->code == Code && ((LPNMHDR)lParam)->idFrom == Id)\
		return handler((LPNMHDR)lParam);

#define ON_COMMAND_MSG(Code, Id, handler) \
	if(message == WM_COMMAND && HIWORD(wParam) == Code && LOWORD(wParam) == Id)\
		return handler(lParam);

#define ON_MSG(msg, handler) \
	if(msg == message)\
	{\
		*pResult = handler(wParam, lParam);\
		return true;\
	}

#define ON_SIZE(handler) \
	if(message == WM_SIZE)\
		return handler(wParam, LOWORD(lParam), HIWORD(lParam));

#define ON_SETFOCUS(handler) \
	if(message == WM_SETFOCUS)\
		return handler((HWND)wParam);

#endif/*_MESSAGE_HANDLERS_H_*/
